home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / database / eb108.zip / PACK1.PRG / EBOUT / EB5.REP < prev    next >
Text File  |  1996-11-10  |  40KB  |  1,109 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.           ═══════════════════════════════════════════════════
  8.           EASY BASE NETWORKING GUIDE                 Contents
  9.           ───────────────────────────────────────────────────
  10.  
  11.           Introduction                               Page   1
  12.           Batch Starting                             Page   3
  13.           Clearing Locks                             Page   4
  14.           Configuration                              Page   6
  15.           Development Work                           Page   7
  16.           File Open On Server                        Page   9
  17.           Lock Directory                             Page  10
  18.           Numbering Records                          Page  11
  19.           Private Keyword                            Page  12
  20.           Protective Locking                         Page  13
  21.           Self Locking Loops                         Page  16
  22.           Strategic Locking                          Page  17
  23.           Terminal Number Val.                       Page  18
  24.           Unique Entries                             Page  19
  25. ................................................................................
  26.      Introduction                                        Introduction
  27.  
  28.      Easy Base Networker has been designed to make the creation of
  29.      multi user data management systems as simple as possible. To do
  30.      this it incorporates automatic locking and privatisation
  31.      routines. With a few exceptions, you can create multi user
  32.      systems just as if you were writing for a stand alone PC.
  33.      The few exceptions are, however, important so please read this
  34.      short guide before attempting to convert any single user
  35.      application.
  36.  
  37.      Because Easy Base is an interpreter, the same program is used
  38.      both for the creation of your application and for running it.
  39.      Only the running routines are multi user. Multiple work
  40.      stations can access the same forms and procedures
  41.      simultaneously only when such forms and procedures are called
  42.      from pre defined user menus. Multiple work stations can access
  43.      the form and procedure design routines (System Menus) provided
  44.      they are each doing design work in different data sub
  45.      directories. No two work stations can access the system menus
  46.      for the same data sub directory at the same time.
  47.  
  48.      Terminology used in this Guide.
  49.  
  50.      PUBLIC FILES:
  51.  
  52.      Files to which all work stations have access. The public files
  53.      are form definition, data and procedure definition files
  54.      together with the network common configuration file.
  55.  
  56.      PRIVATE FILES:
  57.  
  58.      Files for which each work station has its own copy. The private
  59.      files are: user menus, terminal configuration, procedure output
  60.      subindex and temporary forms. You can also write to private
  61.      copies of public form definitions for temporary storage by
  62.      using the keyword "Private".
  63.  
  64.      TERMINAL NUMBER:-
  65.  
  66.      This is a unique number assigned to each work station logged on
  67.      to Easy Base. The terminal number is used in the naming of the
  68.      work station's private files and for recording which work
  69.      station has placed any access lock.
  70.  
  71.      SYSTEM LOCKS
  72.  
  73.      The locks which Easy Base engages to prevent simultaneous
  74.      loading and simultaneous access to the system menus in any one
  75.      data sub directory.
  76.  
  77.      PROTECIVE LOCKS
  78.  
  79.      The locks which Easy Base engages to prevent index file
  80.  
  81.                                 - 1 -
  82. ................................................................................
  83.      Introduction                                        Introduction
  84.  
  85.      corruption during multiple access.
  86.  
  87.      STRATEGIC LOCKS
  88.  
  89.      The locks you set in procedure code when you require a form to
  90.      be locked for non protective reasons.
  91.  
  92.      Easy Base Networker was developed under Novell Personal
  93.      Netware. It does not, however, contain any Novell specific code
  94.      and should be reliable on any DOS based network system.
  95.  
  96.      To get started, install Easy Base to a new directory on a
  97.      server. Allocate a drive letter for your work stations to
  98.      reference this directory and set your network software to allow
  99.      unrestricted read and write access to all files in that
  100.      directory and all sub directories under it.
  101.  
  102.      To log on to Easy Base, three parameters are required. The
  103.      terminal number to use, The data sub directory to operate in
  104.      and a password for either the system menus or a user menu.
  105.  
  106.      From a work station, change to the drive you have allocated and
  107.      type "EB".
  108.  
  109.      When you start Easy Base with the command EB you will be asked
  110.      to supply the three parameters which it requires. All three
  111.      parameters can be supplied automatically either by setting them
  112.      in the environment ( Work stations which self boot ) or by
  113.      placing them on the command line. ( See Batch Starting )
  114.  
  115.      All locking in Easy Base is by "Soft lock". DOS file and record
  116.      locking techniques are not used. With any locking strategy,
  117.      locks can be left engaged if a work station suffers a power
  118.      failure or is switched off without exiting the program. System
  119.      and Access locks which are left engaged after a power failure
  120.      can be cleared by Easy Base or by DOS file erasure.
  121.      (See Clearing Locks )
  122.  
  123.  
  124.  
  125.  
  126.  
  127.      Applications written in previous stand alone versions of Easy
  128.      Base can be copied directly to a sub directory of Easy Base
  129.      Networker. However, the pre processed (.PPR) files created by
  130.      Version 9 are NOT compatible with Network V1 and must be erased
  131.      before use. You can erase all .PPR files by selecting
  132.      Relationships from the main system menu.  The system values
  133.      Total Records, Total Copies and Current Record no longer exist.
  134.      Any procedure which uses these values must be changed. They are
  135.      now available as pseudo fields Form.Total Records, Form.Total
  136.      Copies and Form.Record Number.
  137.  
  138.                                 - 2 -
  139. ................................................................................
  140.      Batch Starting                                    Batch Starting
  141.  
  142.      You can by pass entering any or all of the sign on parameters
  143.      either by setting them in the environment of the work station
  144.      or by supplying them on the command line.
  145.  
  146.      To have a work station automatically log on as terminal 1 in
  147.      the sub directory accounts with the password "Fred", add the
  148.      following lines to the work station's Autoexec.Bat file:-
  149.  
  150.      SET EBT=1
  151.      SET EBD=ACCOUNTS
  152.      SET EBP=FRED
  153.  
  154.      Or start Easy Base with the command line :-
  155.  
  156.      EB T=1 D=ACCOUNTS P=FRED
  157.  
  158.      Any parameters which are not supplied either in the environment
  159.      or on the command line will be asked for on start up.
  160.  
  161.      If you have set the start up parameters for any given work
  162.      station in the environment and you start Easy Base with
  163.      different parameters on the command line, the parameters on the
  164.      command line override those in the environment.
  165.  
  166.      If your application has different passwords for different menu
  167.      structures you can set the terminal number and directory and
  168.      leave the user to supply the password.
  169.  
  170.      If the user has access to different directories then just set
  171.      the terminal number and the user can choose the directory and
  172.      enter the password.
  173.  
  174.      NOVELL WARNING
  175.      ══════════════
  176.  
  177.      If you save a "Login Script" after setting EB environment
  178.      variables and subsequently change the settings in your
  179.      Autoexec.bat file, Novell will swap the setting it saved for
  180.      the new ones whenever you login. Saving a new Login script
  181.      after the change does not rectify the situation. You actually
  182.      have to find the login script file and edit out the old
  183.      environment settings. Under Novell Personal Netware this file
  184.      is called PNWLOGIN.SCR and is stored in a numbered sub
  185.      directory under C:\NWCNTL\MAIL
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                 - 3 -
  196. ................................................................................
  197.      Clearing Locks                                    Clearing Locks
  198.  
  199.      ACCESS LOCKS
  200.  
  201.      If a data access lock is left engaged it can be cleared by
  202.      selecting "Clear Access Locks" from the utilities menu. You can
  203.      also make "Clear Access Locks" available on user menus.
  204.  
  205.      When you run "Clear Access Locks" Easy Base clears all access
  206.      locks in the current data sub directory. Because it clears ALL
  207.      locks in the current directory you should ensure that no other
  208.      work stations currently require locks in place - ie they should
  209.      not be running procedures or adding or modifying records. There
  210.      is no need for them to log out of Easy Base.
  211.  
  212.  
  213.      SYSTEM LOCKS
  214.  
  215.      Easy Base uses two system locks - a loading lock and a System
  216.      Menus lock. Because of the way Easy Base initially loads its
  217.      overlays, no two work stations can load at the same time. When
  218.      a work station attempts to load Easy Base while another work
  219.      station is loading, Easy Base displays the message "Please wait
  220.      another terminal is loading". As soon as the first work station
  221.      has logged on this message will clear and the second will load.
  222.  
  223.      If the first terminal suffers a power failure while loading,
  224.      this lock will be left engaged. If the loading lock does not
  225.      clear within one minute, The "Please wait" message displayed on
  226.      any other work station which is trying to load is replaced with
  227.      one which allows the user to escape and enter the reset
  228.      command.
  229.  
  230.      To clear the loading lock type "EB reset" at the command
  231.      prompt.
  232.  
  233.      Whenever a work station is accessing the system menus for any
  234.      given data sub directory, all other terminals are locked out of
  235.      the system menus in that directory. If a work station is
  236.      powered off without leaving the system menus then this lock
  237.      will be left engaged and no work station will be able to access
  238.      the system menus for that directory. The system menu lock is
  239.      also cleared by typing "EB reset" at the command prompt.
  240.  
  241.      WARNING
  242.  
  243.      It is essential to your data integrity that no two work
  244.      stations log in to Easy Base with the same terminal number. To
  245.      prevent this Easy Base maintains a log of which terminal
  246.      numbers are in use. This log is erased when you issue the
  247.      command "EB reset". If one or more terminals are logged on to
  248.      Easy Base and another issues the command "EB reset" then it
  249.      will be able to log on with a terminal number which is already
  250.      in use. You must prevent this as the two work stations with the
  251.  
  252.                                 - 4 -
  253. ................................................................................
  254.      Clearing Locks                                    Clearing Locks
  255.  
  256.      same terminal number will overwrite each others private files
  257.      and ignore each others data access locks with unpredictable
  258.      results.
  259.  
  260.      If you have arranged for each work station to supply its
  261.      parameters from the environment or from the command line in a
  262.      batch start this is not a problem, but if you allow work
  263.      station operators to choose their terminal number it is.
  264.  
  265.      To be absolutely sure, you should ensure that all work stations
  266.      exit Easy Base before issuing the "EB Reset" command and log
  267.      back in after it.
  268.  
  269.  
  270.  
  271.      DOS LOCK CLEARING
  272.  
  273.      All Easy Base locks can be cleared manually by erasing the
  274.      locking files. The locking files are:-
  275.  
  276.      Loading Lock         EB.LOD        Easy Base Directory
  277.      System Menus Lock    EB.LOG        Easy Base Directory
  278.      Directory Lock       DIR.LOC       Data Directories
  279.      Form Locks           Base(No).LOC  Data Directories
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.                                 - 5 -
  310. ................................................................................
  311.      Configuration                                      Configuration
  312.  
  313.      The utilities Install Printer, Options, Screen Colours and Set
  314.      Paper Length described in the programmers reference are
  315.      combined under "Configuration" on the main menu in the network
  316.      version of Easy Base.  You can also add configuration to a user
  317.      menu.
  318.  
  319.      Apart from date and numeric formatting, all configuration items
  320.      are private to the terminal being configured. You can therefore
  321.      install different printers on different workstations. When you
  322.      install a printer in Easy Base you only have the option to send
  323.      output to LPT1 or LPT2. When you select an LPT port the output
  324.      will be sent either to a printer connected to that port or to a
  325.      network printer that has been mapped to it by your network
  326.      software.
  327.  
  328.      CAUTION:
  329.  
  330.      Novell netware reports three LPT ports on all workstations even
  331.      if they only physically have one. If you set output to LPT2 and
  332.      your workstation has no physical LPT2 and no network printer
  333.      has been mapped to LPT2 then Easy Base will hang up when you
  334.      try to print.
  335.  
  336.      When you change the network common items, date and numeric
  337.      format. They only take effect on other workstations from the
  338.      next time they log in.
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.                                 - 6 -
  367. ................................................................................
  368.      Development Work                                Development Work
  369.  
  370.      When you are doing development work from the system menus there
  371.      should not be any other operator accessing forms or procedures
  372.      in the data directory you are working in. This does not mean
  373.      that you cannot have a second workstation accessing that
  374.      directory under your control. It is in fact preferable to have
  375.      a second workstation for testing purposes. There are aspects of
  376.      design work that Easy Base does not and in some cases cannot
  377.      provide locking for. This section will explain how to avoid
  378.      conflicts.
  379.  
  380.      The only system operations which are fully protected are Data
  381.      entry from the system menus and packing forms. You can perform
  382.      these operations safely even when other operators are active.
  383.  
  384.      Whatever system operation you perform, there will be no
  385.      conflict if the other active workstation/s are at rest
  386.      displaying a user menu.
  387.  
  388.      To make and test modifications to an application, provide
  389.      access to the system menus from your user menu and start your
  390.      application on the user menu for both workstations. One
  391.      workstation can then access the system menus while the other
  392.      remains on the user menu.
  393.  
  394.      After modifying a form or procedure you can then escape to the
  395.      user menu and test the modification in a multi user
  396.      environment.
  397.  
  398.      Modifications to forms, relationships and procedures are
  399.      effective immediately.  Modifications to User Menus, Vat rates
  400.      and network common configuration items take effect the next
  401.      time a workstation logs on or changes directory.
  402.  
  403.      If, for example, you change your user menu structure then you
  404.      must select Change data directory and select the same directory
  405.      again before it is displayed.
  406.  
  407.      If your application is in constant use, you can minimize down
  408.      time by making and testing your modifications in a spare
  409.      directory with a copy of the App. Once you are happy, other
  410.      users only have to be shut down while you make the
  411.      modifications in the live directory and not while you do your
  412.      testing.
  413.  
  414.      If you absolutely have to make modifications without shutting
  415.      down other workstations then there is only one operation which
  416.      can actually corrupt your data. That is if you modify a form
  417.      such that its record length changes. You MUST NOT do this while
  418.      any other workstation is in data entry to that form or is
  419.      running a procedure which updates that form. The other work
  420.      station will continue using the old record length and corrupt
  421.      the data file.  All other operations may or may not cause
  422.  
  423.                                 - 7 -
  424. ................................................................................
  425.      Development Work                                Development Work
  426.  
  427.      spurious system errors on either your workstation or one of the
  428.      others but will not normally affect data.
  429.  
  430.      Whenever you add modify or delete forms, procedures,
  431.      relationships, choice lists or user menus Easy Base erases and
  432.      re writes the definition file and the form, procedure or choice
  433.      list directory file. Any workstation which attempts to read
  434.      from a file between the erase and re write will crash, and your
  435.      workstation will crash if it actions the erase while another
  436.      workstation has the file open.
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.                                 - 8 -
  481. ................................................................................
  482.      File Open on Server                          File Open on Server
  483.  
  484.      If a workstation fails and it had files open at the time, then
  485.      your network server will prevent any other workstation from
  486.      erasing those files before the failed workstation logs back in
  487.      to the network.
  488.  
  489.      There are several processes in Easy Base which erase files.
  490.      These are, packing, the procedure commands "clear records from"
  491.      and "rename temp as" as well as form, relationship and
  492.      procedure modifications from the system menus.
  493.  
  494.      If any workstation suffers a power failure while accessing Easy
  495.      Base you should re start it and log back on to the network as
  496.      soon as possible. If the failed workstation did not have files
  497.      open at the time of the failure then other workstations will
  498.      continue to work normally. If it did have files open then any
  499.      workstation which tries to erase one of those files will crash
  500.      with a "File Open on Server" message.
  501.  
  502.      Any such errors will cease as soon as the failed workstation
  503.      logs back on to the network. If the failure was such that the
  504.      failed workstation cannot be restarted then you must shut down
  505.      and restart the server.
  506.  
  507.      During most activity in Easy Base, it is unlikely that a
  508.      workstation failure will cause problems. There is one major
  509.      exception to this. That is if a workstation fails while packing
  510.      a form.
  511.  
  512.      If a workstation fails while packing a form, Easy Base will
  513.      restart the packing process automatically the first time any
  514.      workstation logs on to that data directory. If the failed
  515.      workstation has not logged back in to the network then any
  516.      other workstation logging on to the data directory will crash
  517.      with the "File Open on Server" message. In other words, no
  518.      workstation will be able to access the data directory until
  519.      either the failed workstation is back on the network or the
  520.      network server has been restarted.
  521.  
  522.      You may also get a "File Open on Server" error if any other
  523.      program such as a fileviewer opens an Easy Base file.
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.                                 - 9 -
  538. ................................................................................
  539.      Lock Directory                                    Lock Directory
  540.  
  541.      When you need to make modifications to an application you can
  542.      prevent other workstations from logging on to the directory you
  543.      are about to modify by selecting "Lock Directory" from the
  544.      utilities menu. If any other workstations are active in the
  545.      directory when you select Lock Directory, Easy Base will list
  546.      their terminal numbers on screen. When all other workstations
  547.      have logged out of the directory the lock will engage.
  548.  
  549.      When you have finished your modifications select "Clear Access
  550.      Locks" to clear the directory lock.
  551.  
  552.      Apart from application modifications, the directory lock should
  553.      be used before backup, restore or data import routines.
  554.  
  555.      Once a directory lock has been set, only a workstation using
  556.      the terminal number which set it can access the directory.
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.                                 - 10 -
  595. ................................................................................
  596.      Numbering Records                              Numbering Records
  597.  
  598.      If you are converting a single user application then you may
  599.      have to adjust your code where records are entered via a
  600.      procedure and each record has to have a consecutive number in
  601.      one of its fields.
  602.  
  603.      In single user applications record numbering is often done by
  604.      having a "Last" form which holds a single record with the last
  605.      record number in it. The procedure which enters new records
  606.      derives the next record number in a field on its input screen
  607.      with the derivation :- Lookup(Last,Number) + 1 and the
  608.      procedure code updates the last form :-
  609.  
  610.      For Last
  611.         Last.number = input.number
  612.         Update record
  613.      Next
  614.  
  615.      In a multi user environment this is not reliable. If another
  616.      workstation starts the procedure after yours has done the
  617.      lookup but before you run the procedure then both workstations
  618.      will derive the same number on screen.
  619.  
  620.      To ensure correct numbering your procedure code must re-check
  621.      the Last.number value when it is run.
  622.  
  623.      For Last
  624.         input.number = last.number + 1
  625.         Last.number = input.number
  626.         Update record
  627.      next
  628.  
  629.      Although this will ensure correct numbering, it may be
  630.      off putting to see the same record number on two screens. To
  631.      avoid this you can declare a variable to pick up the number in
  632.      and delete the input.number field. The code would then be:-
  633.  
  634.      Declare variables
  635.         number as number
  636.      end
  637.      for last
  638.         number = last.number + 1
  639.         Last.number = number
  640.         Update record
  641.      next
  642.      For form new record
  643.         form.number = number
  644.         copy all from input
  645.      next
  646.  
  647.  
  648.  
  649.  
  650.  
  651.                                 - 11 -
  652. ................................................................................
  653.      Private Keyword                                  Private Keyword
  654.  
  655.      One of the main differences between stand alone and multi user
  656.      applications is that where a form is used for temporary storage
  657.      each workstations temporary records must be kept separately.
  658.  
  659.      For example, in an order taking application you might have one
  660.      procedure which looks up stock items and enters them to an
  661.      "OrderItems" form. When all the items have been entered another
  662.      procedure prints out the order and clears down the "OrderItems"
  663.      form. If these procedures are to be used by more than one work
  664.      station then, clearly, the items entered by one station must be
  665.      stored separately from those entered by another.
  666.  
  667.      In many data management systems this would involve separate
  668.      forms and procedures for each work station. In Easy Base you
  669.      can separate data by placing the keyword "Private" at the end
  670.      of any for loop and at the end of the "clear records from"
  671.      command.
  672.  
  673.      In this example the following procedures can be used by any
  674.      number of work stations to create separate orders using the
  675.      same procedures and OrderItems form.
  676.  
  677.      For OrderItems new record private
  678.         Copy all from input
  679.      Next
  680.      .........................................
  681.      For OrderItems private
  682.         Total = Total + orderitems.price
  683.         print list items
  684.      next
  685.      Print report footer
  686.      .........................................
  687.      Clear records from OrderItems private
  688.  
  689.      As an aid to debugging you can view the records which have been
  690.      entered privately for any workstation by pressing Ctrl + P when
  691.      in data entry to the form.
  692.  
  693.      CAUTION
  694.  
  695.      The provision of private data files is for temporary storage in
  696.      applications like the one described above. It is not suitable
  697.      for keeping permanent private records. There are no facilities
  698.      for packing or reformatting the private data file. Private
  699.      records can only be removed with the "Clear records from form
  700.      private" command in procedure code.  If you modify a form which
  701.      has private data records the private data is not reformatted to
  702.      the new form definition and the old data must be erased with
  703.      the "Clear records from" command before use.
  704.  
  705.  
  706.  
  707.  
  708.                                 - 12 -
  709. ................................................................................
  710.      Protective Locking                            Protective Locking
  711.  
  712.      The Easy Base protective locking allows any number of work
  713.      stations to read or write to data files simultaneously where no
  714.      index file is involved. It allows any number of workstations to
  715.      read via the same index file simultaneously but prevents any
  716.      workstation from writing to an index file that is being read
  717.      from. It prevents simultaneous writing to the same index file
  718.      and any file from being erased while in use.
  719.  
  720.      Whenever a workstation attempts a process that is locked by
  721.      another work station Easy Base waits for the lock to be
  722.      released. If the lock is not released within four seconds Easy
  723.      Base displays the message "Waiting for Access - Esc Cancel". If
  724.      the user presses the escape key with this message on screen,
  725.      the process is cancelled. If the process was in data entry to a
  726.      form the workstation remains in data entry to that form and is
  727.      ready to accept any other input. If the process was during a
  728.      procedure then the procedure is terminated. If it had a
  729.      repeating input screen, control returns to the input screen and
  730.      if it did not, control returns to the menu from which it was
  731.      called.
  732.  
  733.      The protective locking routines in Easy Base are automatic
  734.      apart from two options.
  735.  
  736.      1. In certain procedures you will not wish to allow the user
  737.      the option to cancel the procedure when he has to wait for a
  738.      lock to clear. To do this, place the command "Wait" in the
  739.      procedure code after output field and variable declarations.
  740.  
  741.      If the command "Wait" has been issued and the procedure
  742.      encounters a lock which lasts more than four seconds then Easy
  743.      Base still displays the message "Waiting for Access" but the
  744.      escape key is not active.
  745.  
  746.      2. Easy Base provides two options for locking while a procedure
  747.      reads records using an index file. Consider the code:-
  748.  
  749.      For Customers with Surname in order
  750.         Print list items
  751.      next
  752.  
  753.      For this procedure to complete successfully, no other work
  754.      station must write to the index file on Surname during the
  755.      procedure. If there are many records in the customers file and
  756.      the output is being sent to a printer then other workstations
  757.      could be prevented from adding modifying or deleting records in
  758.      the customers form for some considerable time.
  759.  
  760.      As well as reading directly from the Customers.Surname index
  761.      Easy Base can also make a private copy of the index file as it
  762.      stands at the start of the procedure. The Customers form is
  763.      locked only for as long as it takes to make the copy. Once the
  764.  
  765.                                 - 13 -
  766. ................................................................................
  767.      Protective Locking                            Protective Locking
  768.  
  769.      file has been copied, other workstations are free to write to
  770.      the customers form and the procedure selects records using its
  771.      private copy of the index file.
  772.  
  773.      By default, Easy Base locks the form against write processes
  774.      during the procedure. To take the private index option add the
  775.      command "No Lock" to the end of the "For" line.
  776.  
  777.      For Customers with surname in order no lock
  778.  
  779.      There are pros and cons for both methods and the exact nature
  780.      of your application will determine which should be used in any
  781.      given for loop.
  782.  
  783.      The default system prevents writing to the form for the
  784.      duration of the loop but has no anomalies in the output. The
  785.      copy index method locks the form for the minimum time, but if
  786.      the indexed field of any record is altered by another
  787.      workstation the altered record may be processed out of order.
  788.      For example, in this loop, if another workstation changes a
  789.      customers surname from Smith to Jones before the procedure
  790.      reaches the Smiths, you will have a Jones listed among the
  791.      Smiths in your printout because that is the record's position
  792.      in the private index.
  793.  
  794.      The "No Lock" option should only be applied to for loops of
  795.      public files. It should not be applied to any loop which is
  796.      already private. :-
  797.  
  798.      PickList, Temp, any loop using the private keyword and any loop
  799.      using a subindex are automatically private.
  800.  
  801.      EASY BASE AUTOMATIC LOCKING SUMMARY
  802.  
  803.      File Erasure (Packing, Clear records from, Rename temp as) :-
  804.  
  805.      None of these processes will start while any other workstation
  806.      is accessing the form to which they apply. Once they have
  807.      started, no other workstation can access the form until they
  808.      are complete.
  809.  
  810.      Data Entry to forms :-
  811.  
  812.      File erasure is not permitted at any stage. Write locking is
  813.      engaged during an F3 search on an indexed field and while any
  814.      other workstation makes a lookup from one of the forms indexed
  815.      fields. Read and write locking is engaged during F2 add or
  816.      update record and during F7 delete record.
  817.  
  818.      Procedures :-
  819.  
  820.      In procedures, locks are set separately for each "For" loop.
  821.  
  822.                                 - 14 -
  823. ................................................................................
  824.      Protective Locking                            Protective Locking
  825.  
  826.      When loops are nested, the locks set by each loop are retained
  827.      until the procedure exits the outermost loop when they are all
  828.      cleared together.
  829.  
  830.      Loops of Picklist, Temp, Subindex and any loop using the
  831.      private keyword have no locking as the files involved are
  832.      private to the workstation.
  833.  
  834.      Unqualified loops ( For Form ) Lock against file erasure only.
  835.      Loops qualified by "With" set a write lock on the form. Loops
  836.      qualified by "New Record" or containing the commands "Update
  837.      record" or "Delete record" lock the form against read or write.
  838.  
  839.      A loop prefixed by "Index Off" follows the same rules as for
  840.      Packing. It will not start while any other workstation is
  841.      accessing the form and once started, no other workstation can
  842.      access the form until it is finished and the indexes are
  843.      rebuilt.
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.                                 - 15 -
  880. ................................................................................
  881.      Self Locking Loops                            Self Locking Loops
  882.  
  883.      When For Loops of the same form are nested in a procedure Easy
  884.      Base ignores any lock which the workstation has set for the
  885.      outer loop when it starts the nested one. It does not ignore
  886.      any lock set by another workstation. It is therefor possible to
  887.      write a procedure which cannot be run on two workstations
  888.      simultaneously because they will each lock each other.
  889.  
  890.      For parts with number = input.number
  891.         for parts alias addone new record
  892.           copy all from parts
  893.           Addone.number = jointext(input.number,"a")
  894.         next
  895.      next
  896.  
  897.      Although a legitimate procedure in a single user environment,
  898.      this will self lock if run on two workstations. The first line
  899.      sets a read only lock on the parts form. A single workstation
  900.      will ignore its own lock and write the new record but if two
  901.      workstations run the procedure neither will be able to write
  902.      the new record until the other releases its read only lock.
  903.  
  904.      Such procedures are seldom necessary and when they are you can
  905.      avoid the problem by making the read only lock the inner one.
  906.  
  907.      For parts new record
  908.         for parts alias getone with number = input.number
  909.            parts.name = getone.name
  910.            parts.Qty = getone.Qty
  911.            parts.number = jointext(input.number,"a")
  912.         next
  913.      next
  914.  
  915.      Although the convenience of using "Copy all from" has been lost
  916.      this procedure will not self lock. The outer loop now locks
  917.      read and write access to the parts form so any other work
  918.      station attempting to run the same procedure cannot start until
  919.      this one has finished.
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.                                 - 16 -
  937. ................................................................................
  938.      Strategic Locking                              Strategic Locking
  939.  
  940.      Strategic locks are locks which are not covered by the
  941.      automatic protective locking but are none the less necessary
  942.      for the correct operation of an application.
  943.  
  944.      Strategic locks are set by the procedure command Lock and
  945.      cleared by the command Unlock. Strategic locks will not engage
  946.      while any other workstation is accessing the form to be locked
  947.      and once set prevent any other workstation from accessing the
  948.      form before the Unlock command has been issued.
  949.  
  950.      Each Lock command must have a matching Unlock command but they
  951.      need not necessarily be in the same procedure. If a form has to
  952.      be locked while several procedures run from a batch menu, for
  953.      example, then the first procedure can lock the form and the
  954.      last can unlock it.
  955.  
  956.      Strategic locks are seldom required in applications which
  957.      simply store and report on data. In transactional applications
  958.      however, they are often essential.
  959.  
  960.      As an example, a form "Work" contains records of the hours
  961.      worked by employees - one record for each time each employee
  962.      clocks in. Each record also has a number field and procedures
  963.      which enter records to the form derive the record number field
  964.      from a form "Last" which contains a single record with the last
  965.      record number in form "Work".
  966.  
  967.      When a single employees records are deleted from the form, the
  968.      form is packed, the records are renumbered and the entry in the
  969.      "Last" form is updated with the new number of records in "Work"
  970.  
  971.      The Easy Base protective locking will prevent any other work
  972.      station from entering a new record during the deletion loop and
  973.      during the pack. It will not prevent it from entering a new
  974.      record between the deletion loop and the pack or between the
  975.      pack and the updating of the "Last" form. To ensure that no
  976.      other workstation adds a new record to work before the "Last"
  977.      form is updated the "Last" form must be locked throughout.
  978.  
  979.      Lock Last
  980.      For Work with employee = input.employee
  981.         Delete record
  982.      Next
  983.      Pack Work
  984.      For Last
  985.         For Work
  986.            x = x + 1 : Work.number = x
  987.            Update record
  988.         Next
  989.         Last.number = x : Update Record
  990.      Next
  991.      Unlock Last
  992.  
  993.                                 - 17 -
  994. ................................................................................
  995.      Terminal Number Val.                        Terminal Number Val.
  996.  
  997.      The System value "Terminal Number" is available in field
  998.      derivations and procedure code and returns the terminal number
  999.      used to log on to Easy Base.
  1000.  
  1001.      The main use of the Terminal Number value is to privatize
  1002.      lookups in temporary storage forms. As an example, an invoicing
  1003.      system might have one procedure which looks up a customers
  1004.      number from the "customers" form and looks up the next invoice
  1005.      number from the "last" form. It then enters a record in the
  1006.      "current" form so that the next procedure, which looks up stock
  1007.      items and enters them privately to the "invoicelines" form, can
  1008.      automatically lookup the "Current.Customer" and
  1009.      "Current.invoice".
  1010.  
  1011.      If multi workstations are to use these procedures at the same
  1012.      time then each must be able to lookup its own Current.Customer
  1013.      and Current.Invoice. To do this, in say a six terminal
  1014.      application, six records are pre entered to the "current" form
  1015.      with the values 1,2,3,4,5 and 6 in the terminal field.
  1016.  
  1017.      The first procedure has the code:-
  1018.  
  1019.      Declare variables
  1020.         No as number
  1021.      end
  1022.      for last
  1023.         No = last.invoiceno + 1
  1024.         last.invoiceno = No
  1025.         Update record
  1026.      next
  1027.      for current with terminal = terminal number
  1028.         current.customer = input.customer
  1029.         current.invoiceno = no
  1030.         Update record
  1031.      Next
  1032.  
  1033.      The procedure which enters the invoicelines has a hidden field
  1034.      "Terminal" derived :- Terminal Number and looks up the current
  1035.      invoice number and customer based on a relationship linking
  1036.      this field with the terminal field in the "Current" form.
  1037.  
  1038.      The Terminal Number value can also be used to create private
  1039.      entries in public forms. If a public form "Notes" has a field
  1040.      "Terminal" and each workstation enters its notes together with
  1041.      its terminal number then the procedure:
  1042.  
  1043.      For Notes with terminal = terminal number
  1044.         Print list items
  1045.      next
  1046.  
  1047.      Will only print the notes entered by the workstation running
  1048.      the procedure.
  1049.  
  1050.                                 - 18 -
  1051. ................................................................................
  1052.      Unique Entries                                    Unique Entries
  1053.  
  1054.      Where new records are entered to forms via procedures and one
  1055.      of the fields in the form must be unique, the procedure must
  1056.      test to see if the value it is about to enter in the unique
  1057.      field already exists. In single user applications this test can
  1058.      be accomplished solely on the input screen.
  1059.  
  1060.      To check a unique field "Name" in form Parts the input screen
  1061.      name field would be derived:-
  1062.  
  1063.      If(lookup(parts,name) = name,blank[beepPart Name Exists !Cursor
  1064.      name],name)
  1065.  
  1066.      In a multi user environment this is no longer reliable. If two
  1067.      workstations enter the same name on their input screens at the
  1068.      same time they will both pass the lookup test above. To ensure
  1069.      a unique entry you must re check if the value exists at the
  1070.      start of the procedure code and return to the input screen if
  1071.      the value has been taken since the field was filled.
  1072.  
  1073.      Declare variables
  1074.         x as number
  1075.      end
  1076.      For parts new record
  1077.         for parts alias checkit with name = input.name
  1078.            x = x + 1
  1079.         next
  1080.         if x > 0 then
  1081.            beep
  1082.            Display Status "This part name already exists !"
  1083.            Delay 2000
  1084.            Recall input screen
  1085.         end if
  1086.         copy all from input
  1087.      next
  1088.  
  1089.      When the line "For parts new record" is processed, the parts
  1090.      form is locked so no other workstation can add a record. If the
  1091.      name does not exist then the procedure adds the new record but
  1092.      if it does the operator is warned by the beep and status
  1093.      display and the procedure returns to the input screen without
  1094.      adding the new record.
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.                                 - 19 -
  1108. ................................................................................
  1109.